package madixin.t1154;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

class Solution {
    public int dayOfYear(String date) {
        DateFormat s = new SimpleDateFormat("yyyy-MM-dd");
        String year = date.substring(0, 4);

        Date curDate = null;
        Date firstDate = null;
        try {
            curDate = s.parse(date);
            firstDate = s.parse(year + "-01-01");
        } catch (ParseException e) {
            return 0;
        }

        long span = curDate.getTime() - firstDate.getTime();
        return (int) (span / 3600 / 24 / 1000) + 1;
    }

    public static void main(String[] args) {
        Solution s = new Solution();
        System.out.println(s.dayOfYear("2019-12-30"));
    }
}
